Repository navigation
fix: harden child compaction journal writes - #13
Merged
Merged
Conversation
sambitcreate
marked this pull request as ready for review
August 9, 2026 15:37
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — one commit hardening child-agent Pi journal writes against append failures, plus coverage registration.
- Journal flush resilience — the child compaction loop now wraps
appendSessionMessagesin aflushPiMessagestry/catch that retains the failed message batch and reports the error through an injectableonPiJournalErrorhook, matching the primary chat loop pattern inllm-client.ts:1599-1614. - Injectable
SubagentRuntimeRegistryOptions—appendPiMessagesandonPiJournalErrorare constructor-injectable test seams, defaulting to the realappendPiMessagesandwriteDevLogfor production. The constructor signature change is additive and backward compatible. - Regression test — validates that a child completion survives an injected journal failure, the assistant message remains in
agent.state.messages, the error hook fires exactly once, and the registry cleans up. - Coverage registration —
test:compactionadded topretest:coverageandpi-compaction-core.test.tsadded to thetest:coveragefile list.
DeepSeek Pro | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Root cause
The primary chat loop already wrapped Pi journal flushes, but the child loop cleared its pending batch and directly awaited the append. A write rejection therefore discarded the retryable batch and failed the child task after the provider had completed successfully. The compaction suite was also absent from the coverage path.
Impact
Child-agent completions now remain usable if the in-memory Pi journal append fails, while compaction stops safely for that child. Coverage runs now execute and measure the compaction-core suite.
Validation
npm run type-checknpx eslint main/services/subagents/child-agent-runtime.ts main/services/subagents/agent-compatibility.test.tsnpm run test:compaction(7 passed)npx tsx --test main/services/subagents/agent-compatibility.test.ts(27 passed)npm run test:subagents:phase6b(90 passed)npx tsx --test --experimental-test-coverage main/services/pi-compaction-core.test.tsnpm run build:electron